#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

class Point
{
public:
    Point(int x = 0, int y = 0)
        :_x(x)
        ,_y(y)
    {}
    int getX() const { return _x; }
    int getY() const { return _y; }
private:
    int _x;
    int _y;
};

class Rectangle
{
public:
    Rectangle(int num = 0, int x = 0, int y = 0, int width = 0, int height = 0)
        :_num(num)
        , _topLeft(x, y)
        , _width(width)
        , _height(height)
    {}
    int getArea() const { return _width * _height; }
    int getNum() const { return _num; }
    bool isIn(Point p) const;
private:
    int _num;
    Point _topLeft;
    int _width;
    int _height;
};

bool Rectangle::isIn(Point p) const
{
    int x = _topLeft.getX();
    int y = _topLeft.getY();
    return p.getX() > x && p.getX() < x + _width
        && p.getY() > y && p.getY() < y + _height;
}

class RectangleCollection
{
public:
    void addRectangle(Rectangle r) { if (_count < 100)_rects[_count++] = r; }
    void deleteRectangle(int num);
    int inRects(Point p);
private:
    Rectangle _rects[100];
    int _count = 0;
};

void RectangleCollection::deleteRectangle(int num)
{
    for (int i = 0; i < _count; i++)
        if (_rects[i].getNum() == num)
            _rects[i] = _rects[--_count];
}

int RectangleCollection::inRects(Point p)
{
    int ret = 0;
    for (int i = 0; i < _count; i++)
        if (_rects[i].isIn(p))
            ret += _rects[i].getArea();
    return ret;
}

int main()
{
    int num, topLeftX, topLeftY, width, height;
    int px, py;
    int op;
    RectangleCollection rc;
    Rectangle r;
    Point p;

    while (cin >> op)
    {
        switch (op)
        {
        case 1:
            cin >> num >> topLeftX >> topLeftY >> width >> height;
            r = Rectangle(num, topLeftX, topLeftY, width, height);
            rc.addRectangle(r);
            break;
        case 2:
            cin >> num;
            rc.deleteRectangle(num);
            break;
        case 3:
            cin >> px >> py;
            p = Point(px, py);
            cout << rc.inRects(p) << endl;
            break;
        }
    }
    return 0;
}
